//
//  AuthPresenter.m
//  ApeExample
//
//  Created by Eton on 2017/7/27.
//  Copyright © 2017年 王-庭协. All rights reserved.
//

#import "LoginPresenter.h"
#import "AppRequest+Auth.h"

@implementation LoginPresenter

- (RACSignal *)enableLoginSignal{
    if (!_enableLoginSignal) {
        _enableLoginSignal = [RACSignal combineLatest:@[RACObserve(self, account),RACObserve(self, pwd)] reduce:^id(NSString *account,NSString *pwd){
            return @(account.length && pwd.length);
        }];
    }
    return _enableLoginSignal;
}

- (RACCommand *)loginCommand{
    if (!_loginCommand) {
        _loginCommand  = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(RACTuple *turple) {
            return [AppRequest requestLogin:[RACTuple tupleWithObjects:turple.first,turple.second, nil]];
        }];
    }
    
    return _loginCommand;
}

@end
